﻿@model IEnumerable<HQPad.Models.Invocation>

@{
    ViewBag.Title = "Invocations";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    int rulesId = (int)ViewBag.RuleSetID;
}

@section PageScripts {
    <script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
}

<h1>Invocations</h1>


<section class="content">

<div class="block">
    <p>@Html.ActionLink("Create New", "Create", new { ruleSetId = rulesId }, new { @class = "button" })</p>
</div>

<div class="block">
    @using (Html.BeginForm("Index", "Invocation", "Post"))
    {
        <h2>Filter</h2>
        <ul class="filters">
            <li>Sphere: @Html.DropDownList("Sphere", "All")</li>
            <li>Guild: @Html.DropDownList("Guild","All")</li>
        </ul>

        <script type="text/javascript">
            $(document).ready(function () {
                $('.goFilter').click(function (event) {
                    // get qs parameters.
                    var value = $('#Sphere').val();
                    var newUrl;
                    newUrl = addToUrl(window.location.href, 'sphere', value);

                    value = $('#Guild').val();
                    newUrl = addToUrl(newUrl, 'guild', value);

                    $(this).attr('href', newUrl);
                });
            });
        </script>
    
        <p><a href='#' class="goFilter button" >Filter</a></p>
    }

    <table>
        <tr>
            <th>
                Name
            </th>
            <th>
                Rank
            </th>
            <th>
                Sphere
            </th>
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Rank)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Sphere)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { ruleSetId = item.RuleSetID, slug=item.Slug.ToLower() }) |
                @Html.ActionLink("Delete", "Delete", new { ruleSetId = item.RuleSetID, slug = item.Slug.ToLower() })
            </td>
        </tr>
    }

    </table>

</div>

</section>